Public Class Form1 Dim keys(100) As Integer Dim movies(100) As String Dim numMovies As Integer Private Function ExtractLine(ByVal text As String, ByRef line As String, ByRef startPos As Integer, ByRef foundPos As Integer) As Boolean ' find the next occurrence of the new line char foundPos = text.IndexOf(ControlChars.NewLine, startPos) ' check if it was found If foundPos = -1 Then Return False Else ' pull out the current line of the file line = text.Substring(startPos, foundPos - startPos) ' update the starting point for search startPos = foundPos + 2 Return True End If End Function Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim allText As String Dim lineExists As Boolean Dim currentDVD As String Dim start As Integer = 0 Dim foundPos As Integer ' check if file exists If My.Computer.FileSystem.FileExists("info.txt") Then ' read the file contents allText = My.Computer.FileSystem.ReadAllText("info.txt") ' while not at end, extract line Do lineExists = ExtractLine(allText, currentDVD, start, foundPos) If lineExists Then ' stick the line in the rich text box box rtbCheatersList.AppendText(currentDVD & ControlChars.NewLine) Dim movie As String Dim keyStr As String Dim key As Integer Dim commaPos As Integer commaPos = currentDVD.IndexOf(",") keyStr = currentDVD.Substring(0, commaPos) movie = currentDVD.Substring(commaPos + 1) Dim isConverted As Boolean isConverted = Integer.TryParse(keyStr, key) If isConverted Then keys(numMovies) = key movies(numMovies) = movie 'MsgBox("movie read in - movie: " & movies(numMovies) _ ' & " key: " & keys(numMovies)) numMovies = numMovies + 1 End If End If Loop While lineExists 'Array.Sort(keys) 'Array.Sort(movies) Else MsgBox("Please put the info.txt file in the bin folder for the project") End If End Sub Private Sub btnLookUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLookUp.Click Dim key As Integer Dim keyStr As String Dim isconverted As Boolean Dim found As Boolean = False isconverted = Integer.TryParse(txtToFind.Text, key) If isconverted Then Dim cnt As Integer For cnt = 0 To numMovies - 1 If key = keys(cnt) Then found = True txtFound.Text = movies(cnt) End If Next cnt If Not found Then MsgBox("that movie is not found") End If Else MsgBox("please enter a whole number to search for") End If End Sub End Class